#ifndef SYSTEMSETTING_H
#define SYSTEMSETTING_H

#include <QWidget>
#include <QStandardItemModel>
#include <QDateTime>
#include "databasemanager.h"

namespace Ui {
class SystemSetting;
}

class SystemSetting : public QWidget
{
    Q_OBJECT

public:
    explicit SystemSetting(QWidget *parent = nullptr);
    ~SystemSetting();

    static void log(const QString &content,
                  const QString &logType = "system",
                  const QString &logLevel = "INFO",
                  int userId = -1,
                  int deviceId = -1);

private slots:
    void onQueryLogs();
    void onExportLogs();
    void showContextMenu(const QPoint &pos);
    void deleteSelectedLog();

private:
    Ui::SystemSetting *ui;
    QStandardItemModel *m_logsModel;
    DatabaseManager* m_dbManager;

    void setupModel();
    void setupConnections();
    void populateTypeComboBox();
    void populateLevelComboBox();

public:
    void loadLogs();
    QString buildQueryString() const;
    void setDatabaseManager(DatabaseManager* );
};

#endif // SYSTEMSETTING_H
